import 'package:flutter_eve_plugin/constants/constant.dart';
import 'package:flutter_eve_plugin/model/health/sys_health_property.dart';
import 'package:flutter_eve_plugin/model/health/user_body_property.dart';
import 'package:flutter_eve_plugin/pages/main/actions.dart';
import 'package:flutter_eve_plugin/plugin/main.dart';
import 'package:flutter_eve_plugin/store/base_action.dart';
import 'package:redux/redux.dart';
import 'package:redux_thunk/redux_thunk.dart';
import 'constant.dart';

healthPropertyHealth(Store store, PropertyHealthModel model) {
  if (model == null) return;
  store.dispatch(BaseAction(type: HEALTH_PROPERTY_HEALTH, data: model));
}

healthPropertyBody(Store store, UserBodyModel model) {
  if (model == null) return;
  store.dispatch(BaseAction(type: HEALTH_PROPERTY_BODY, data: model));
}

healthSysCurrPage(Store store, int index) {
  store.dispatch(BaseAction(type: HEALTH_SYS_CURR_PAGE, data: index));
}

ThunkAction initData() {
  return (Store store) async {
    PluginEve.sendMessage(PluginConstant.httpHealthHome, httpType: HttpType.POST).then(
            (data) => healthPropertyHealth(store, data));
    PluginEve.sendMessage(PluginConstant.httpHealthBody, httpType: HttpType.POST)
        .then((data) => healthPropertyBody(store, data));
    PluginEve.sendMessage(PluginConstant.httpUserInfo, httpType: HttpType.POST)
        .then((data) => userInfo(store, data));
  };
}

ThunkAction allGoodsType() {
  return (Store store) async {
    PluginEve.sendMessage(PluginConstant.httpAllGoodsType, httpType: HttpType.POST);
  };
}
